package com.sdleyou.treepro.common.rabbitmq.sender;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.sdleyou.treepro.common.constant.Constants;
import com.sdleyou.treepro.common.model.dao.UserPetDO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ImmediateSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(UserPetDO userPetDO, int delayTime) {
        this.rabbitTemplate.convertAndSend(Constants.DEAD_LETTER_EXCHANGE, Constants.DELAY_ROUTING_KEY, userPetDO, message -> {
            message.getMessageProperties().setExpiration(delayTime + "");
            return message;
        });
    }
}